function getOrder() {
    data = []
    for (let i = 0; i < 10; i++) {
        let pet_list = []

        for (let j = 0; j < 3; j++) {
            let res = Mock.mock({
                'pet_name': Random.cname(),
                'number': Random.integer(0, 10),
                'image': Random.image(),
                'price': Random.float(100,1000,2,2)
            })

            pet_list.push(res)
        }

        let res = Mock.mock({
            'order_number': /O[0-9]{11}/,
            'date': Random.datetime(),
            'order_status': /[0-3]/,
            'pet_list': pet_list,
            'price' : Random.float(100,1000,2,2)
        })

        data.push(res)
    }

    json = {
        data,
        'code' : 200,
        'msg' : '获取成功',
        'nowPage' : 2,
        'totalPage' : 8
    }

    return json
}

function getOrderDetail(){
    let pet_list = []

    for (let j = 0; j < 3; j++) {
        let res = Mock.mock({
            'pet_name': Random.cname(),
            'number': Random.integer(0, 10),
            'image': Random.image(),
            'price': Random.float(100,1000,2,2)
        })

        pet_list.push(res)
    }

    let data = Mock.mock({
        'order_number': /O[0-9]{11}/,
        'date': Random.datetime(),
        'order_status': /[0-3]/,
        'pet_list': pet_list,
        'price' : Random.float(100,1000,2,2)
    })

    json = {
        data,
        code:200,
        msg:'获取成功'
    }

    return json
}

Random = Mock.Random

Mock.mock('http://localhost/orders.php', 'post', getOrder)

Mock.mock(/http:\/\/localhost\/order_detail.php.*?/, 'post', getOrderDetail)

